from database.models.wechat_model import WechatData


class AdventWechatOperation:

    @staticmethod
    def create_group_in_wechat(group_name, member_list):
        """
        group_name: 企业微信群名称
        member_list: 企业微信群昵称列表
        return: 群id、群主、群成员id列表
        """
        wechat_group_id, owner, userid_list = WechatData.create_wechat_group(group_name, member_list)
        WechatData.insert_wechat_group_info(wechat_group_id, group_name, owner, userid_list)
        return wechat_group_id, owner, userid_list

    @staticmethod
    def send_text_msg_to_wechat_group(wechat_group_id, message):
        """
        wechat_group_id： 群id
        message_type：消息类型 text、image、voice、video、file
        message：消息内容
        """
        WechatData.send_wechat_text_message(wechat_group_id, message)

    @staticmethod
    def send_file_to_wechat_group(wechat_group_id, file_path):
        """
        wechat_group_id： 群id
        message_type：消息类型 text、image、voice、video、file
        message：消息内容
        """
        WechatData.send_file_to_wechat_group(wechat_group_id, file_path)


if __name__ == '__main__':
    AdventWechatOperation.create_group_in_wechat("20250322测试群", ["陈荣博", "赵东栋"])
    # message = "您好！\n你负责的产品发生变更，请检查！"
    # wechat_group_id = "wr8HbdZQAACLHpYtj2ZIZreKIxinFZOg"
    # WechatData.send_wechat_text_message(wechat_group_id, message)
    wechat_group_id = "wr8HbdZQAAqdiAfsFd9yllzgU3ytAEaQ"
    file_path = r"C:\Users\Administrator\Desktop\测试企业微信发送文件.xlsx"
    AdventWechatOperation.send_file_to_wechat_group(wechat_group_id, file_path)
